import 'core-js/stable'
import 'regenerator-runtime/runtime'
import Vue, { DirectiveOptions } from 'vue'

import 'normalize.css'
import ElementUI from 'element-ui'
import SvgIcon from 'vue-svgicon'
import 'element-ui/lib/theme-chalk/fonts/element-icons.ttf'
import 'element-ui/lib/theme-chalk/fonts/element-icons.woff'

import '@/styles/index.scss'

import App from '@/App.vue'
import store from '@/store'
import { AppModule } from '@/store/modules/app'
import router from '@/router'
import i18n from '@/lang'
import '@/icons/components'
import '@/icons/iconfont/font_1816419_7nzg63w5irk.css'
import '@/icons/iconfont/font_1708339_rspp408u1i.css'
import '@/icons/iconfont/iconfont.css'
import '@/permission'
import '@/utils/error-log'
import '@/pwa/register-service-worker'
import * as directives from '@/directives'
import * as filters from '@/filters'
import * as LANGUAGE from '@/lang/old'
import * as tunnyApi from '@/api/tunnyApi'
import PandaApi from '@/api/pandaApi'
import EagleApi from '@/api/eagle'
import VueCookies from 'vue-cookies'
import OrinusApi from './api/orinusApi'
import OrsApi from './api/orsApi'
import GentianApi from './api/gentianApi'
import * as CloudTunnyApi from './api/cloudTunnyApi'
import ConsoleHeader from 'consoleHeader'
import SystemTunnyApi from './api/systemTunnyApi'

// import _ElSelect from "@/components/Basic/Select/select.vue";

Vue.use(ElementUI, {
  size: AppModule.size, // Set element-ui default size
  i18n: (key: string, value: string) => i18n.t(key, value)
})

Vue.use(SvgIcon, {
  tagName: 'svg-icon',
  defaultWidth: '1em',
  defaultHeight: '1em'
})

// Register global directives
Object.keys(directives).forEach(key => {
  Vue.directive(key, (directives as { [key: string ]: DirectiveOptions })[key])
})

// Register global filter functions
Object.keys(filters).forEach(key => {
  Vue.filter(key, (filters as { [key: string ]: Function })[key])
})

Vue.config.productionTip = false

Vue.prototype._ = LANGUAGE.__

Vue.prototype.$tunnyApi = tunnyApi

Vue.prototype.$pandaApi = new PandaApi()

Vue.prototype.$eagleApi = new EagleApi()

Vue.prototype.$orinusApi = new OrinusApi()

Vue.prototype.$orsApi = new OrsApi()

Vue.prototype.$cloudTunnyApi = CloudTunnyApi

Vue.prototype.$gentianApi = new GentianApi()

Vue.prototype.$systemTunnyApi = new SystemTunnyApi()

Vue.use(VueCookies)

Vue.use(ConsoleHeader)

Vue.prototype.$url_prefix = process.env.VUE_APP_URL_PREFIX;
// if (location.hash.indexOf("faq") === -1) {
//   // const opScript = document.createElement("script");
//   // opScript.src = "hhhhhhhhh";
//   let opCss = process.env.VUE_APP_OP_HEADER_CSS_URL
//   let opJs = process.env.VUE_APP_OP_HEADER_JS_URL
//   const opLink = document.createElement("link");
//   const opScript = document.createElement("script");
//   opLink.href = opCss || "";
//   opScript.src = opJs || "";
//   document.head.append(opLink);
//   document.body.append(opScript);

//   opScript.onload = () => {
//     const ConsoleHeader: any = require('consoleHeader');
//     Vue.use(ConsoleHeader);
//     Vue.component("ConsoleHeader", ConsoleHeader);
//   }
// }

// Vue.component("el-select", _ElSelect);

(window as any).context = new Vue({
  router,
  store,
  i18n,
  render: (h) => h(App)
}).$mount('#app')
